package mapper;

import entity.User;
import entity.UserExample;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;

import java.util.List;
//@CacheNamespace
public interface UserMapper {
    long countByExample(UserExample example);

    int deleteByExample(UserExample example);

    int deleteByPrimaryKey(Integer id);

    int insert(User record);

    int insertSelective(User record);

    //仅仅当前方法不会走缓存
    //@Options(useCache = false)
    //@Options(flushCache = Options.FlushCachePolicy.TRUE)
    User selectUserById(int id);


    List<User> selectAllUser();



    User selectUserByNameAndAge(@Param("username") String username,@Param("sex") String sex);

    int updateUser(User user);

    //不仅仅自己不能命中，别人也不能命中(清空全部缓存)
    //@Options(flushCache = Options.FlushCachePolicy.TRUE)
    User selectUserById1(int id);
   //@Options(flushCache = Options.FlushCachePolicy.TRUE)
    User selectUserById2(int id);


    List<User> selectByExample(UserExample example);

    User selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") User record, @Param("example") UserExample example);

    int updateByExample(@Param("record") User record, @Param("example") UserExample example);

    int updateByPrimaryKeySelective(User record);

    int updateByPrimaryKey(User record);
}
